#ifndef DESKTOPWEBVIEW_H
#define DESKTOPWEBVIEW_H

#include "abstractwebview.h"
#include <QWebEngineView>
#include <QWebChannel>

class DesktopWebView : public AbstractWebView
{
    Q_OBJECT
public:
    explicit DesktopWebView(QWidget *parent = nullptr);
    ~DesktopWebView();

    void setUrl(const QUrl &url) override;
    void evaluateJavaScript(const QString &script, const std::function<void(const QVariant&)>& callback) override;
    QString syncJavaScript(const QString &script) override;
    void addJavaScriptObject(const QString &name, QObject *obj) override;
    void stop() override;
    void reload() override;

    // 获取底层的 WebEngineView
    QWebEngineView* webView() const { return m_pWebView; }

private:
    QWebEngineView *m_pWebView;
    QWebChannel *m_pChannel;

    // AbstractWebView interface
public:
};

#endif // DESKTOPWEBVIEW_H 
